package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.messgeDistribute.ScreenMessageDistributeDTO;
import com.hzeport.bgs22emduty.dto.messgeDistribute.ScreenMessageDistributeHideDTO;
import com.hzeport.bgs22emduty.dto.messgeDistribute.ScreenMessageDistributeRemoveDTO;
import com.hzeport.bgs22emduty.dto.messgeDistribute.ScreenMessageDistributeSaveDTO;
import com.hzeport.bgs22emduty.entity.ScreenMessageDistribute;
import com.hzeport.bgs22emduty.enums.HideStatusEnum;
import com.hzeport.bgs22emduty.service.ScreenMessageDistributeService;
import com.hzeport.bgs22emduty.vo.ScreenNotice.ScreenNoticeSaveVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screenmessagedistribute")
@Api(value = "screenmessagedistribute", tags = "值班信息下发管理")
@Slf4j
public class ScreenMessageDistributeController {

    private final ScreenMessageDistributeService screenMessageDistributeService;

    private final LoginCompoentService loginCompoentService;

    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public BaseResult< Page<ScreenMessageDistribute>> getScreenMessageDistributePage(@RequestBody ScreenMessageDistributeDTO screenMessageDistribute) {
        Page<ScreenMessageDistribute>  dutyMessageList
                = screenMessageDistributeService.getScreenMessageDistributePage(screenMessageDistribute);
        return BaseResult.ok(dutyMessageList);
    }

    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("getById")
    public BaseResult getById(@RequestParam("id") String id) {
        return BaseResult.ok(screenMessageDistributeService.detail(id));
    }


    @ApiOperation(value = "新增${comments}", notes = "新增${comments}")
    @PostMapping("save")
    @OperLog(systemName = "ZBXXXF",description = "XXXZ")
    public BaseResult save(@Valid@RequestBody ScreenMessageDistributeSaveDTO screenMessageDistributeSaveDTO) throws Exception {
        return BaseResult.ok(screenMessageDistributeService.saveExperiences(screenMessageDistributeSaveDTO));
    }


    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
//    @ApiOperation(value = "通过id隐藏", notes = "通过id隐藏")
//    //@SysLog(.*)
//    @PostMapping("/hide")
//    public BaseResult hide(@Valid @RequestBody ScreenMessageDistributeHideDTO screenMessageDistributeHideDTO) {
//        if (HideStatusEnum.NOT_HIDED.getValue().equals(screenMessageDistributeHideDTO.getStatus())) {
//            return BaseResult.ok(screenMessageDistributeService.hide(screenMessageDistributeHideDTO),"取消隐藏成功");
//        }else {
//            return BaseResult.ok(screenMessageDistributeService.hide(screenMessageDistributeHideDTO),"隐藏成功");
//        }
//    }

    @ApiOperation(value = "通过id隐藏", notes = "通过id隐藏")
    //@SysLog(.*)
    @PostMapping("/hide")
    @OperLog(systemName = "ZBXXXF",description = "XXYC")
    public BaseResult hide(@Valid @RequestBody ScreenMessageDistributeHideDTO screenMessageDistributeHideDTO) {
        if (HideStatusEnum.NOT_HIDED.getValue().equals(screenMessageDistributeHideDTO.getStatus())) {
            return BaseResult.ok(screenMessageDistributeService.hide(screenMessageDistributeHideDTO),"取消隐藏成功");
        }else {
            return BaseResult.ok(screenMessageDistributeService.hide(screenMessageDistributeHideDTO),"隐藏成功");
        }
    }

    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    //@SysLog(.*)
    @PostMapping("/delete")
    @OperLog(systemName = "ZBXXXF",description = "XXSC")
    public BaseResult remove(@Valid @RequestBody ScreenMessageDistributeRemoveDTO screenMessageDistributeRemoveDTO) {
        return BaseResult.ok(screenMessageDistributeService.remove(screenMessageDistributeRemoveDTO));
    }

    @ApiOperation(value = "置顶/取消置顶")
    @RequestMapping(value = "topping",method = RequestMethod.POST)
    @OperLog(systemName = "ZBXXXF",description = "XXZD")
    public  BaseResult<String> topping(@RequestBody ScreenMessageDistributeHideDTO dto) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  screenMessageDistributeService.topping(dto,dto);
    }

}
